#include "BaseCamera.h"
#include "Common/Constants.h"

static const float DEFAULT_FOV  = PI * 0.25f;
static const float DEFAULT_FAR  = 1000.0f;
static const float DEFAULT_NEAR = 1.0f;
static const float DEFAULT_ASPECT = 1.0f;

CBaseCamera::CBaseCamera()
	: m_vPosition(0.0f, 0.0f, 0.0f)
	, m_vRight(1.0f, 0.0f, 0.0f)
	, m_vLook(0.0f, 0.0f, 0.0f)
	, m_vUp(0.0f, 1.0f, 0.0f)
	, m_fFov(DEFAULT_FOV)
	, m_fFar(DEFAULT_FAR)
	, m_fNear(DEFAULT_NEAR)
	, m_fAspect(DEFAULT_ASPECT)
{
	D3DXMatrixIdentity(&m_mWorldMatrix);
	D3DXMatrixIdentity(&m_mViewMatrix);
	D3DXMatrixIdentity(&m_mProjMatrix);
}

CBaseCamera::~CBaseCamera()
{

}

void CBaseCamera::Update( float fTime )
{
	//D3DXMatrixTranslation(&m_mWorldMatrix, m_vPosition.x, m_vPosition.y, m_vPosition.z);

	_ComputeViewMatrix();
	_ComputeProjMatrix();
}

void CBaseCamera::Render()
{

}

void CBaseCamera::_ComputeViewMatrix()
{
	D3DXMatrixLookAtLH(&m_mViewMatrix, &m_vPosition, &m_vLook, &m_vUp);
}

void CBaseCamera::_ComputeProjMatrix()
{
	D3DXMatrixPerspectiveFovLH(&m_mProjMatrix, m_fFov, m_fAspect, m_fNear, m_fFar);	
}

